<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

<%@ page import="fr.mywiki.business.navigation.NavigationManager" %>
<%@ page import="fr.mywiki.business.navigation.SpaceFlyweight" %>
<%@ page import="java.util.Iterator" %>

<html:form action="spaces">
	<html:hidden property="method" value="display" />
	<html:hidden property="spaceName" value="" />
	
<script>
<!--
function changeSpace(space) {
	document.forms["spacesForm"].method.value='changeSpace';
	document.forms["spacesForm"].spaceName.value=space;
	document.forms["spacesForm"].submit();
}
-->
</script>
	
	<div id="spacesPanel">
		<ul>
<%
	Iterator itSpaces = NavigationManager.getSpaces(session).iterator();
	String currentSpace = NavigationManager.getCurrentSpace(session).getName();
	while(itSpaces.hasNext()) {
		SpaceFlyweight space = (SpaceFlyweight) itSpaces.next();
%>				
				<li>
<%
		if(!currentSpace.equals(space.getName())) {
%>
						<a href="#" 
								onclick="javascript:changeSpace('<%=space.getName() %>');"/>
							<bean:message key="<%=space.getTitle()%>"/>
						</a>&nbsp;
<%
		} else {
%>
						<bean:message key="<%=space.getTitle()%>"/>&nbsp;
<%
		}
%>
				</li>
<%
	}
%>
		</ul>
	</div>
</html:form>